//
//  DataModel.m
//  构架模式MVC
//
//  Created by XHJ on 2020/8/24.
//  Copyright © 2020 L. All rights reserved.
//

#import "DataModel.h"

@interface DataModel ()


@end

@implementation DataModel

+ (DataModel *)modelWithDictionary:(id)dic {
    DataModel *model = [[DataModel alloc] init];
    [model setValuesForKeysWithDictionary:dic];
    return model;
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {}

+ (void)loadDataSuccess:(void (^)(id _Nonnull))sucess failure:(void (^)(void))failure {
    NSArray *dataArray = @[@{@"name":@"小红", @"subName":@"狗蛋"},
                           @{@"name":@"小王", @"subName":@"石头"},
                           @{@"name":@"小张", @"subName":@"土豆"},
                           @{@"name":@"小李", @"subName":@"狗蛋1"},
                           @{@"name":@"小海", @"subName":@"石头2"},
                           @{@"name":@"小明", @"subName":@"土豆3"}];
    NSMutableArray *tempArr = [NSMutableArray array];
    for (NSDictionary *dic in dataArray) {
        DataModel *model = [DataModel modelWithDictionary:dic];
        NSLog(@" model : %@", model.name);
        [tempArr addObject:model];
    }
    sucess(tempArr);
}
@end
